package com.clarence.dada.modular.system.dict.controller;


import com.clarence.dada.core.base.BaseReq;
import com.clarence.dada.core.base.PageResult;
import com.clarence.dada.core.base.Result;
import com.clarence.dada.modular.system.dict.entity.req.DictTypeReq;
import com.clarence.dada.modular.system.dict.entity.resp.SysDictTypeResp;
import com.clarence.dada.modular.system.dict.service.DictTypeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 字典类型管理
 *
 * @author GD
 * @since 2020/10/30 21:46
 */
@RestController
@RequestMapping("/system/dictType/")
@Tag(name = "字典类型管理", description = "字典类型管理Controller")
public class DictTypeController {

    @Resource
    private DictTypeService dictTypeService;

    /**
     * 添加字典类型
     *
     * @author GD
     * @since 2018/7/25 下午12:36
     */
    @Operation(summary = "系统字典类型_新增", description = "新增字典类型")
    @PostMapping("dictTypeAdd")
    public Result<Void> dictTypeAdd(@RequestBody @Validated(DictTypeReq.add.class) DictTypeReq req) {
        this.dictTypeService.dictTypeAdd(req);
        return Result.SUCCESS;
    }

    /**
     * 删除字典类型
     *
     * @author GD
     * @since 2018/7/25 下午12:36
     */
    @Operation(summary = "系统字典类型_删除", description = "删除字典类型")
    @PostMapping("dictTypeDelete")
    public Result<Void> dictTypeDelete(@RequestBody @Validated(DictTypeReq.delete.class) DictTypeReq req) {
        this.dictTypeService.dictTypeDelete(req);
        return Result.SUCCESS;
    }

    /**
     * 获取字典类型详情
     *
     * @author GD
     * @since 2021/1/13 11:25
     */
    @Operation(summary = "系统字典类型_详情", description = "获取字典类型详情")
    @GetMapping("dictTypeDetail")
    public Result<SysDictTypeResp> dictTypeDetail(@Validated(BaseReq.detail.class) DictTypeReq req) {
        return new Result<>(this.dictTypeService.dictTypeDetail(req));
    }

    /**
     * 获取字典类型列表(分页)
     *
     * @author GD
     * @since 2020/10/30 21:46
     */
    @Operation(summary = "系统字典类型_列表(分页)", description = "获取字典类型列表(分页)")
    @GetMapping("dictTypePage")
    public Result<PageResult<SysDictTypeResp>> dictTypePage(DictTypeReq req) {
        return new Result<>(dictTypeService.dictTypePage(req));
    }

    /**
     * 获取字典类型详情
     *
     * @author GD
     * @since 2021/1/13 11:25
     */
    @Operation(summary = "获取系统配置字典类型详情", description = "获取系统配置字典类型详情")
    @GetMapping("getConfigDictTypeDetail")
    public Result<SysDictTypeResp> getConfigDictTypeDetail() {
        DictTypeReq req = new DictTypeReq();
        req.setDictTypeCode("config_group");
        SysDictTypeResp detail = this.dictTypeService.dictTypeDetail(req);
        return new Result<>(detail);
    }


}
